﻿using WpfTestApplication;

namespace NUnitTests{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Guia.Core;
    using Guia.Elements;
    using NUnit.Framework;

    /// <summary>
    /// Summary description for SliderTest
    /// </summary>
    [TestFixture]
    public class SliderTest : AbstractWindowTest
    {

        #region Overrides of AbstractWindowTest

        protected override Type TestWindowType()
        {
            return typeof(SliderTestWindow);
        }

        protected override string TestWindowName()
        {
            return "SliderTestWindow";
        }

        #endregion

        [Test]
        public void TestMinimum()
        {
            Slider slider = window.Get<Slider>("slider1");
            Assert.AreEqual(-5, slider.Minimum);
        }

        [Test]
        public void TestMaximum()
        {
            Slider slider = window.Get<Slider>("slider1");
            Assert.AreEqual(15,slider.Maximum);
        }

        [Test]
        public void TestSmallChange()
        {
            Slider slider = window.Get<Slider>("slider1");
            Assert.AreEqual(0.1,slider.SmallChange);
        }

        [Test]
        public void TestLargeChange()
        {
            Slider slider = window.Get<Slider>("slider1");
            Assert.AreEqual(1,slider.LargeChange);
        }

        [Test]
        public void TestSmallIncrease()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.SmallIncrease();
            Assert.AreEqual(0.1,slider.Value);
        }

        [Test]
        public void TestSmallDecrease()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.SmallDecrease();
            Assert.AreEqual(-0.1, slider.Value);
        }

        [Test]
        public void TestLargeIncrease()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.LargeIncrease();
            Assert.AreEqual(1,slider.Value);
        }

        [Test]
        public void TestLargeDecrease()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.LargeDecrease();
            Assert.AreEqual(-1, slider.Value);
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestToLargeValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = 20;
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestToSmallValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = -10;
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestSmallIncreaseInvalidValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = 15;
            slider.SmallIncrease();
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestSmallDecreaseInvalidValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = -5;
            slider.SmallDecrease();
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestLargeIncreaseInvalidValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = 14.5;
            slider.LargeIncrease();
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestLargeDecreaseInvalidValue()
        {
            Slider slider = window.Get<Slider>("slider1");
            slider.Value = -4.9;
            slider.LargeDecrease();
        }

        [Test, ExpectedException(typeof(OperationNotSupportedException))]
        public void TestSetValueSliderDisabled()
        {
            Slider slider = window.Get<Slider>("slider2");
            slider.Value = 1;
        }
    }
}
